package com.xxl.job.executor.crawler;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.junit.Before;
import org.junit.Test;

public class TestHibernate {
    Configuration config = null;
    SessionFactory sessionFactory = null;
    Session session = null;
    Transaction tx = null;
    @Before
    public void init() {
        config = new Configuration().configure("/hibernate.cfg.xml");
        sessionFactory = config.buildSessionFactory();
        session = sessionFactory.openSession();
        tx = session.beginTransaction();
    }
   /* //增加
    @Test
    public void insert() {
        BdasCrawlerProductEntity ue = new BdasCrawlerProductEntity();
        ue.setProductId("12121212");
        session.save(ue);
        tx.commit();
    }*/
    //修改
  /*  @Test
    public void update() {
        BdasCrawlerProductEntity user = (BdasCrawlerProductEntity) session.get(BdasCrawlerProductEntity.class, new Integer(2));
        session.update(user);
        tx.commit();
        session.close();
    }
    //查找
    @Test
    public void getById() {
        BdasCrawlerProductEntity user = (BdasCrawlerProductEntity) session.get(BdasCrawlerProductEntity.class, new Integer(8));
        tx.commit();
        session.close();

    }
    //删除
    @Test
    public void delete() {
        BdasCrawlerProductEntity user = (BdasCrawlerProductEntity) session.get(BdasCrawlerProductEntity.class, new Integer(6));
        session.delete(user);
        tx.commit();
        session.close();
    }*/
}